package com.cloudkinto.dto.platform.product;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiResponses;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
public class PlatformProductDto {

    private Long id;
    @ApiModelProperty("管理番号")
    private String parentSku;
    private String platformSku;
    @ApiModelProperty("库存预留占比 默认5%")
    private Double stockPercent;
    private Long storeId;

    private Integer storePresale;

    private Integer productPresale;

    private String storeName;

    private Date createTime;


    @ApiModelProperty("图片")
    private String imageUrl;

    @ApiModelProperty("asin")
    private String asin;

    @ApiModelProperty("fn_sku")
    private String fnSku;

    @ApiModelProperty("产品分类")
    private String productType;

    @ApiModelProperty("配送方式")
    private String fulfillmentChannelCode;

    @ApiModelProperty("是否库存联动 0否 1是")
    private Integer inventoryLink;

    @ApiModelProperty("低库存 0否 1是")
    private Integer inventoryLess;

    @ApiModelProperty("产品名称")
    private String itemName;

    @ApiModelProperty("平台库存")
    private Integer platLeftQuantity;

    @ApiModelProperty("亚马逊 配货准备时间")
    private String shippingDayId;


    @ApiModelProperty("系统可用库存")
    private Integer systemCanUseAmount;

    @ApiModelProperty("日销量")
    private Double dailySales;
//    @ApiModelProperty("可售天数")
//    private Double canSellDay;
    @ApiModelProperty("昨日销量")
    private int yesDaysSales;
    @ApiModelProperty("7日销量")
    private double threeDaysSales;
    @ApiModelProperty("14日销量")
    private double sevenDaysSales;
    @ApiModelProperty("30销量")
    private double thirtyDaysSales;

    @ApiModelProperty("近7日权重")
    private double threeDaysWeight;
    @ApiModelProperty("近14日权重")
    private double sevenDaysWeight;
    @ApiModelProperty("近30日权重")
    private double thirtyDaysWeight;


    private List<PlatformProductMappingDto> mappings;

    public String getShippingDayId() {
        if (Objects.equals(shippingDayId, "-1")) {
            return null;
        }
        return shippingDayId;
    }

    public Double getStockPercent() {
        if (stockPercent == null || (stockPercent < 0 || stockPercent > 1)) {
            return 0.05d;
        }
        return stockPercent;
    }

    public Integer getInventoryLink() {
        if (inventoryLink == null) {
            return 0;
        }
        return inventoryLink;
    }
}
